package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.CommendReply;
import cn.wolfcode.trip.base.domain.DailyComment;
import cn.wolfcode.trip.base.domain.Reply;
import cn.wolfcode.trip.base.query.CommendReplyQueryObject;

import cn.wolfcode.trip.base.service.ICommendReplyService;

import cn.wolfcode.trip.base.service.IReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/commendReplys")
public class CommendReplyController {
    @Autowired
    private ICommendReplyService commendReplyService;
    @Autowired
    private IReplyService replyService;


    //根据评论id查询评论
    @GetMapping("{strategyCommentId}")
    public Object listCommendReply(CommendReplyQueryObject qo){
        qo.setOrderBy("cp.commendTime desc");
        return commendReplyService.query(qo);
    }

    @PostMapping
    public void save(CommendReply commendReply){
        commendReplyService.saveOrUpdate(commendReply);
    }
    //保存评论的回复
    @PostMapping("{parent.id}/replys")
    public Object saveReply(Reply reply) {
        replyService.save(reply);
        return replyService.getReply(reply.getId());
    }




}
